<script lang="ts" setup>
import { ref } from 'vue';
import { getgetMyScoreLi } from '/api/training';

const data = ref({})

uni.showLoading();
getgetMyScoreLi().then((res) => {
	uni.hideLoading();
	data.value = res?.data || {};
})
</script>

<template>
	<view class="T_page">
		<view class="card">
			<view class="total">
				<view>{{ data.totalScore }}</view>
				<text>总学分</text>
			</view>
			<view class="items">
				<view>
					<view>{{ data.compulsoryScore }}</view>
					<text>自组织培训</text>
				</view>
				<view>
					<view>{{ data.practiceScore }}</view>
					<text>其他</text>
				</view>
			</view>
		</view>
		<view class="list">
			<view v-for="item in data.scoreRecordList" :key="item.id">
				<view class="left">
					<view>{{ item.trainingTitle }}</view>
					<text>{{ item.updateTime }}</text>
				</view>
				<view class="right">+{{ item.trainingScore }}</view>
			</view>
		</view>
	</view>
</template>

<style lang="scss" scoped>
.card {
	background-color: #fff;
	border-radius: 20rpx;
	padding: 30rpx;

	>.total {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 10rpx;

		view {
			font-size: 36rpx;
			font-weight: bold;
			color: #3B82F6;
		}

		text {
			font-size: 28rpx;
			color: #6B7280;
		}
	}

	>.items {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 30rpx;
		margin-top: 30rpx;

		>view {
			padding: 30rpx;
			background-color: #f8f8f8;
			border-radius: 20rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			gap: 10rpx;

			&:nth-child(1)>view {
				color: #22C55E;
			}

			view {
				font-size: 32rpx;
				font-weight: bold;
				color: #3B82F6;
			}

			text {
				font-size: 24rpx;
				color: #6B7280;
			}
		}
	}
}

.list {
	background-color: #fff;
	border-radius: 20rpx;
	margin-top: 30rpx;
	padding: 0 30rpx;
	overflow-y: auto;

	>view {
		min-height: 120rpx;
		padding: 20rpx 0;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		gap: 20rpx;
		border-bottom: 1px solid #f8f8f8;

		&:last-child {
			border-bottom: none;
		}

		.left {
			flex-grow: 1;

			view {
				color: #1F2937;
			}

			text {
				display: block;
				margin-top: 10rpx;
				font-size: 24rpx;
				color: #6B7280;
			}
		}

		.right {
			flex-shrink: 0;
			color: #22C55E;
			font-size: 30rpx;
		}
	}
}
</style>
